#include<iostream>
#include<cstring>
using namespace std;
const int N=510,M=1e4+100;
int dist[N],back[N];
int n,m,k;


struct edg{
	int a;
	int b;
	int w;
}Edg[M];

bool bellman_ford(){
	memset(dist,0x3f,sizeof dist);
	dist[1]=0;
	for(int i=0;i<k;i++){
		memcpy(back,dist,sizeof dist);
		 for(int i=0;i<m;i++){
		 	dist[Edg[i].b]=min(dist[Edg[i].b],back[Edg[i].a]+Edg[i].w);
		 }
	}
	return dist[n]>0x3f3f3f3f/2;
}



int main(){
	cin>>n>>m>>k;
	for(int i=0;i<m;i++){
		cin>>Edg[i].a>>Edg[i].b>>Edg[i].w;
	}
	if(!bellman_ford()){
		cout<<dist[n];
	}
	else{
		cout<<"impossible";
	}
	return 0;
} 
